<?php
/**
 * Created by PhpStorm.
 * User: songques
 * Date: 2018/4/28
 * Time: 18:40
 */

namespace veda\util;

use think\Session;

class BotCPMTool
{

    /*
    public static  $array_header_ios=[
        'host',
        'upgrade-insecure-requests',
        'accept',
        'user-agent',
        'accept-language',
        'accept-encoding',
        'connection',
    ];
    */

    public static  $array_header_ios=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'accept',
        'user-agent',
        'accept-language',
        'cookie',
        'cf-connecting-ip',
    ];


    public static  $array_header_ios_repeat=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'accept',
        'user-agent',
        'accept-language',
        'cookie',
        'cf-connecting-ip',
    ];



    public static  $array_header_ios_secret=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'accept',
        'user-agent',
        'accept-language',
        'dnt',
        'cf-connecting-ip',
    ];

    public static  $array_header_ios_secret_repeat=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'accept',
        'user-agent',
        'accept-language',
        'dnt',
        'cookie',
        'cf-connecting-ip',
    ];

    public static  $array_header_ios_enable_cookie=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'user-agent',
        'accept',
        'accept-language',
        'cf-connecting-ip',
    ];



    /*
    public static  $array_header_android=[
        'host',
        'connection',
        'upgrade-insecure-requests',
        'user-agent',
        'accept',
        'accept-encoding',
        'accept-language',
    ];
    */



    public static  $array_header_android=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'upgrade-insecure-requests',
        'user-agent',
        'accept',
        'accept-language',
        'cookie',
        'cf-connecting-ip',

    ];

    public static  $array_header_android_repeat=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'cache-control',
        'upgrade-insecure-requests',
        'user-agent',
        'accept',
        'accept-language',
        'cookie',
        'cf-connecting-ip',
    ];

    public static  $array_header_android_secret=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'upgrade-insecure-requests',
        'user-agent',
        'accept',
        'accept-language',
        'cf-connecting-ip',
    ];

    public static  $array_header_android_secret_repeat=[
        'host',
        'connection',
        'accept-encoding',
        'cf-ipcountry',
        'x-forwarded-for',
        'cf-ray',
        'x-forwarded-proto',
        'cf-visitor',
        'cache-control',
        'upgrade-insecure-requests',
        'user-agent',
        'accept',
        'accept-language',
        'cookie',
        'cf-connecting-ip',
    ];


    public static function build_javascript_iframe($offer_url,$url_parameter){

        $offer_url=$offer_url.self::build_url_ques($url_parameter);

        $javascript="ad_idzone = \"00000\";  ad_width = \"300\";  ad_height = \"100\"; ad_sub = \"00000\"; if(top===self) var p=document.URL; else var p=document.referrer;var dt=new Date().getTime();".
            "var exoDocumentProtocol = (document.location.protocol != \"https:\" && document.location.protocol != \"http:\") ? \"https:\" : document.location.protocol;".
            "if(typeof ad_sub == 'undefined') var ad_sub = \"\";".
            "var ad_type = ad_width + 'x' + ad_height;".
            "if(ad_width == '100%' && ad_height == '100%') ad_type = 'auto';".
            "var ad_screen_resolution = screen.width + 'x' + screen.height;".
            "document.write('<iframe id=exoEvent frameborder=0 scrolling=no width=300 height=100 src=".$offer_url."></iframe>');";

        return $javascript;

    }

    public static  function  build_url_ques($requesr_url){
        $url=$requesr_url;
        if(strpos($url,'?')){
            $url=substr($url,strpos($url,'?'),strlen($url)-strpos($url,'?'));
        }else{
            $url='';
        }
        return $url;
    }
}